home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / SDKs / Word Services SDK 1.0.6 / Writeswell Jr 1.2.1 Sources ƒ / Library Source / AboutVersion.c next >
Encoding:
C/C++ Source or Header  |  1995-09-11  |  1.6 KB  |  88 lines  |  [TEXT/MMCC]

  1. /* AboutVersion.c
  2.  * Display a version number in an about box
  3.  * Copyright ©1993 Working Software, Inc.  All Rights Reserved.
  4.  * 23 Feb Mike Crawford
  5.  */
  6.  
  7. /* Create an "AboutVersionDef.h" for each project that defines the constant rVersID.
  8.  */
  9.  
  10. #include "AboutVersion.h"
  11. #include "AboutVersionDef.h"
  12.  
  13. void InstallAboutVersionProc( DialogPtr aboutDialog, short versItem )
  14. {
  15.     short        kind;
  16.     Handle        h;
  17.     Rect        r;
  18.     UserItemUPP    versProc;
  19.  
  20.     GetDItem( aboutDialog, versItem, &kind, &h, &r );
  21.     
  22.     versProc = NewUserItemProc( AboutVersionProc );
  23.     if ( !versProc )
  24.         return;                // STUB should report an error 
  25.  
  26.  
  27.     SetDItem( aboutDialog, versItem, kind, (Handle)versProc, &r );
  28.  
  29.     return;
  30. }
  31.  
  32. void DestroyAboutVersionProc( DialogPtr aboutDialog, short versItem )
  33. {
  34.     short        kind;
  35.     Handle        h;
  36.     Rect        r;
  37.  
  38. #ifdef GENERATINGCFM
  39.     GetDItem( aboutDialog, versItem, &kind, &h, &r );
  40.  
  41.     DisposeRoutineDescriptor( (UniversalProcPtr)h );
  42. #endif
  43.     return;
  44. }
  45.  
  46. pascal void AboutVersionProc( DialogPtr dlg, short item )
  47. {
  48.     Handle        h;
  49.     short        kind;
  50.     Rect        r;
  51.     GrafPtr        oldPort;
  52.     VersRecHndl    versH;
  53.     
  54.     /* From Writeswell Jr. -- draw the version number by getting it from the vers
  55.      * resource.  Saves a lot of time when making a new master disk
  56.      */
  57.          
  58.     versH = (VersRecHndl)Get1Resource( 'vers', rVersID );
  59.  
  60.     if ( !versH ){
  61.         return;
  62.     }
  63.     
  64.     GetPort( &oldPort );
  65.     SetPort( dlg );
  66.     
  67.     GetDItem( dlg, item, &kind, &h, &r );
  68.     
  69.     MoveTo( r.left, r.bottom );
  70.     
  71.     HLock( (Handle) versH );
  72.     
  73.     PenNormal();
  74.     TextFont( applFont );
  75.     TextSize( 12 );
  76.     TextFace( 0 );
  77.  
  78.     DrawString( (*versH)->shortVersion );
  79.     
  80.     HUnlock( (Handle) versH );
  81.     ReleaseResource( (Handle) versH );
  82.     
  83.     SetPort( oldPort );
  84.  
  85.     return;
  86. }
  87.  
  88.